#include <iostream>
#include "Matrix.h"
using namespace std;

int main(int argc, char* argv[])
{
    //输入矩阵
    int r1, c1, r2, c2;
    cin >> r1;
    cin >> c1;
    cin >> r2;
    cin >> c2;
    Matrix<double> A(r1, c1);
    Matrix<double> B(r2, c2);
    Matrix<double> C(r1, c2);

    for (int i = 0; i < r1; i++)
        for (int j = 0; j < c1; j++)
    	    cin >> A(i, j);

    for (int i = 0; i < r2; i++)
        for (int j = 0; j < c2; j++)
    	    cin >> B(i, j);

    //判断是否方阵，返回布尔变量
    A.is_square(A);
    B.is_square(B);

    //矩阵乘法，返回矩阵T类
    C = A * B;
    
    for (int i = 0; i < r1; i++)
    {
    	for (int j = 0; j < c2; j++)
    	    cout << C(i, j) << "\t";
    	cout << endl;
    }

    //输入行列向量
    int n1, n2;
    double p1, p2, p3;
    Matrix<double> p4(n1, n1);
    cin >> n1;
    cin >> n2;
    RowVector<double> x(n1);
    RowVector<double> y(n2);
    ColVector<double> z(n1);
    ColVector<double> w(n2);

    for (int i = 0; i < n1; i++)
	cin >> x(i);
    for (int i = 0; i < n2; i++)
	cin >> y(i);
    for (int i = 0; i < n1; i++)
	cin >> z(i);
    for (int i = 0; i < n2; i++)
	cin >> w(i);

    //行向量乘行向量，返回内积T类
    p1 = x * y;

    //列向量乘列向量，返回内积T类
    p2 = z * w;

    //行向量乘列向量，返回数值T类（其实也可不定义）
    p3 = x * z;

    //列向量乘行向量，自动返回矩阵T类（无需再定义功能，*不满足以上三条时自动使用矩阵乘法）
    p4 = z * x;
    
    cout << "RowVector * RowVector = " << p1 << endl;
    cout << "ColVector * ColVector = " << p2 << endl;
    cout << "RowVector * ColVector = " << p3 << endl;
    cout << "ColVector * RowVector = " << endl << "{" << endl;
    for (int i = 0; i < n1; i++)
    {
    	for (int j = 0; j < n1; j++)
    	    cout << p4(i, j) << "\t";
    	cout << endl;
    }
    cout << "}" <<endl;
    return 0;
}
    
